package com.example.juc.big_talk_concurrent.chapter2.article8;

public class SingleTon {
    // 私有化构造方法
    private SingleTon() {
    }

    private static volatile SingleTon instance = null;

    public static SingleTon getInstance() {
        // 第一次校验
        if (instance == null) {
            synchronized (SingleTon.class) {
                // 第二次校验
                if (instance == null) {
                    instance = new SingleTon();
                }
            }
        }
        return instance;
    }

}

